<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>沙立方</title>
		<meta name="description" content="">
		<meta name="keywords" content="">
		<meta name="renderer" content="webkit">
		<!-- 设置缩放 -->
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimal-ui" />
		<!-- 可隐藏地址栏，仅针对IOS的Safari（注：IOS7.0版本以后，safari上已看不到效果） -->
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!-- 仅针对IOS的Safari顶端状态条的样式（可选default/black/black-translucent ） -->
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<!-- IOS中禁用将数字识别为电话号码/忽略Android平台中对邮箱地址的识别 -->
		<meta name="format-detection" content="telephone=no, email=no" />
		<!-- 启用360浏览器的极速模式(webkit) -->
		<meta name="renderer" content="webkit">
		<!-- 避免IE使用兼容模式 -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="HandheldFriendly" content="true">
		<!-- 微软的老式浏览器 -->
		<meta name="MobileOptimized" content="320">
		<!-- uc强制竖屏 -->
		<meta name="screen-orientation" content="portrait">
		<!-- QQ强制竖屏 -->
		<meta name="x5-orientation" content="portrait">
		<!-- UC强制全屏 -->
		<meta name="full-screen" content="yes">
		<!-- QQ强制全屏 -->
		<meta name="x5-fullscreen" content="true">
		<!-- UC应用模式 -->
		<meta name="browsermode" content="application">
		<!-- QQ应用模式 -->
		<meta name="x5-page-mode" content="app">
		<!-- windows phone 点击无高光 -->
		<meta name="msapplication-tap-highlight" content="no">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" href="../../assets/city/jquery-weui.min.css" />
		<link rel="icon" type="image/png" href="../../assets/i/favicon.png">
		<link rel="stylesheet" href="../../assets/css/amazeui.min.css" />
		<link rel="stylesheet" href="../../assets/css/app.css">
		<link rel="stylesheet" href="../../assets/css/yttApp.css">
		<style>
		   .weui-picker-modal.picker-columns.city-picker.weui-picker-modal-visible{bottom:0px!important;}
		</style>
	</head>

	<body class="bg-fff index_edit">
		<header data-am-widget="header" class="am-header bg-white am-header-fixed bg-085492">
			<div class="am-header-left am-header-nav text-black am-header-left padding-left05" id="goBackDivs">
				<a  href="javascript:history.go(-1)" class="text-black" id="goBackIcon">
				  	<i class="am-align-left am-margin-0 am-icon-angle-left am-icon-md text-black co-fff"></i>
				  </a> 
			</div>
			<h1 class="am-header-title teblack">
				<a href="#title-link" class="co-fff">账户资料</a>
			</h1>
		</header>
		<div class="am-container am-padding-0">
			<form class="am-form reg" method="get" action="" id="regfrom" enctype="multipart/form-data">
                <!-- <div class="changePhone borB-EF borT-EF">
                    <div class="titleDiv"><span class="borLefts">更换手机号</span></div>
                    <div class="am-form-group" style="margin-bottom:10px;">
                        <div class="inputDiv">
                           <span class="labelDiv">原手机号</span>
                           <input type="text" class="inputs" id="phone" name="phone" />
                        </div>
					</div>
					<div class="am-form-group" style="margin-bottom:10px;">
                        <div class="inputDiv">
                           <span class="labelDiv">新手机号</span>
                           <input type="text" class="inputs" id="phones" name="phones" placeholder="请输入新手机号" />
                        </div>
					</div>
					<div class="am-form-group" style="margin-bottom:10px;">
                        <div class="codeDiv">
                           <input type="text" class="inputCode" id="code" name="code" />
                           <button class="getBtn">获取验证码</button>
                        </div>
					</div>
                </div> -->
                <div class="changePhone borB-EF borT-EF">
                    <div class="titleDiv"><span class="borLefts">我的地址</span></div>
                    <div class="am-form-group" style="margin-bottom:10px;">
                        <div class="inputDiv">
                           <input type="text" class="inputs" id="citys" name="citys" placeholder="请选择住址" style="font-size:1.3rem" />
                        </div>
                        <div class="font12 addr1_validation" style="color:red;display:none">请输入我的地址</div>
					</div>
                </div>
                <div class="changePhone borB-EF borT-EF">
                    <div class="titleDiv"><span class="borLefts">详细地址</span><span class="am-hide tishi" style="color:#888;font-size:10px;">（填写赠送10立方币）</span></div>
                    <div class="am-form-group" style="margin-bottom:10px;">
                        <div class="inputDiv">
                           <input type="text" class="inputs" id="citys_jd" placeholder="请输入您的详细地址" style="font-size:1.3rem" />
                        </div>
                        <div class="font12 addr2_validation" style="color:red;display:none">详细地址必填且需大于3个字</div>
					</div>
                </div>
                
                <div class="am-form-group">
					<button id="register" type="button">确认修改</button>
				</div>
			</form>
		</div>
		<div class="am-modal am-modal-loading am-modal-no-btn radius4" tabindex="-1" id="my-modal-loading" data-am-modal="{closeViaDimmer: 0}">
		  <div class="am-modal-dialog" style="border-radius: 4px;">
		    	<div class="am-modal-hd">加载中...</div>
			    <div class="am-modal-bd">
			      <span class="am-icon-spinner am-icon-spin"></span>
			    </div>
		  </div>
		</div>
		
		<div class="am-modal am-modal-alert" tabindex="-1" id="alert1" data-am-modal="{closeViaDimmer: 0}">
		  <div class="am-modal-dialog" style="border-radius: 4px;">
		    	<div class="am-modal-hd"></div>
			   	<div class="am-modal-bd alert1"></div>
		   		<div class="am-modal-footer">
		      		<span class="am-modal-btn" data-am-modal-confirm>确定</span>
		    	</div>
	  		</div>
		</div>
		<script src="../../assets/js/jquery.min.js"></script>
		<script src="../../assets/js/jquery.cookie.js"></script>
		<script src="../../assets/city/jquery-weui.min.js"></script>
		<script src="../../assets/city/city-picker.min.js"></script>
		<script src="../../assets/js/amazeui.min.js"></script>
		<script src="../../assets/js/fastclick.min.js"></script>
		<script src="../../js/comm.js"></script>
		<script src="../../js/slf.js"></script>
		<script>
		$(function(){
			$('.inputs').on('click',function(){
				$('.addr1_validation').css('display','none');
				$('.addr2_validation').css('display','none');
			})
            if(slf.checkSign){
                //已登录
                $(".yk_div").addClass("am-hide").next(".ydl_div").removeClass("am-hide");
                findUser();//查询用户信息
                //修改点击
                update()
                /* 地址选择 */
                $("#citys").cityPicker({
                    title: "选择省市区/县",
                    onChange: function(picker, values, displayValues) {}
                });
            }else{
                //游客
                $(".yk_div").removeClass("am-hide").next(".ydl_div").addClass("am-hide")
            }
		});
        /* 获取用户信息 */
        function findUser(){
            slf.ajax({
                url : "/myCenter/getUserInfo",
                success : function(data){
                    console.log(data)
                    console.log("获取返回信息")
                    if(data.res==1){
                        var addressArray=data.obj.address.split(' ');
                        $("#citys").val(addressArray[0]+' '+addressArray[1]+' '+addressArray[2]);
                        if(data.obj.detailedAddress!=undefined&&data.obj.detailedAddress!=null&&data.obj.detailedAddress!=''){
                        	$('#citys_jd').val(data.obj.detailedAddress);
                        }else{
                        	$(".tishi").removeClass("am-hide")
                        }
                    }
                }
            });
        }
       //修改地址点击事件
        function update(){
            $("#register").click(function(){
                var address=$.trim($("#citys").val());
                var addressDetails=$.trim($("#citys_jd").val());
                if(address==""||address==undefined||address==null){
                	$('.addr1_validation').css('display','block');
                }else if(addressDetails==""||addressDetails==null||addressDetails==undefined||addressDetails.length<4){
    				$('.addr2_validation').css('display','block');
                }else{
                	 slf.ajax({
                         url : "/myCenter/updateUserInfo",
						 type : "post",
                         param : {
                             address : address,
                             detailedAddress : addressDetails
                         },
                         success : function(data){
                             console.log(data)
                             if(data.res==1){
                                 $('.alert1').html(data.resMsg);
                                 $('#alert1').modal({
                                	 closeViaDimmer: false,
                                	 onConfirm: function(options) {
                                		 window.location.href = "index.html"
                                	 }
                                 });
                             }else{
                             	 $('.alert1').html(data.resMsg);
                                 $('#alert1').modal({
                                	 closeViaDimmer: false,
                                 });
                             }
                         },error:function(){
                             console.log("失败")
                         }
                     });
                }
            });
		}
		</script>
	</body>

</html>